{% extends "opda/base.html" %}
{% block page_script %}
    <script type="application/javascript">
    $(function(){
        $('#upload_btn').click(function(){
            if($('#name').val() == ''){
                alert('请输入一个名字，用来标识文件');
            }else{
                $('form').submit();
            }
        });
    });
    </script>
{% endblock %}
{% block mid %}
    <div class="col-lg-10 col-lg-offset-1">
        <div class="col-lg-8 col-lg-offset-1">
            <form class="form-inline" method="post" action="/upload/apk/" enctype="multipart/form-data">
                <label for="name">名称</label>
                <input type="text" name="name" id="name">
                <div class="form-group col-lg-offset-1">
                    <input type="file" name="package">
                </div>

                <input type="button" id="upload_btn" value="上传" class="btn btn-default">
            </form>
        </div>
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th>名称</th>
                    <th>文件名</th>
                    <th>下载</th>
                    <th>大小</th>
                    <th>上传时间</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {% for p in package %}
                    <tr>
                        <td>{{ p.name }}</td>
                        <td>{{ p.file_name }}</td>
                        <td><a href="/down/{{ p.url }}.apk">下载</a></td>
                        <td>{{ p.size }}</td>
                        <td>{{ p.update_time }}</td>
                        <td><a href="/delpackage/{{ p.id }}" class="btn btn-default">删除</a></td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
{% endblock %}